-
Couldn't load subscription status.
- Fork 152
Add poison state to sandbox #931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces sandbox poisoning functionality to prevent further operations when a sandbox is in an inconsistent state that could compromise memory safety. The sandbox becomes poisoned when guest functions abort/panic or when host-initiated execution cancellation occurs.
Key changes:
- Added poisoned state tracking with safety checks across all sandbox operations
- Implemented automatic poison detection for specific error types (GuestAborted, ExecutionCanceledByHost)
- Added recovery mechanisms through snapshot restoration or manual poison clearing
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/hyperlight_host/src/sandbox/initialized_multi_use.rs | Core implementation of poison state tracking, safety checks, and recovery mechanisms |
| src/hyperlight_host/src/error.rs | Added PoisonedSandbox error variant with detailed documentation |
| src/hyperlight_host/tests/integration_test.rs | Updated interrupt tests to clear poison state for continued execution |
| src/hyperlight_host/src/sandbox/snapshot.rs | Added Debug trait to Snapshot struct |
| src/hyperlight_host/src/mem/shared_mem_snapshot.rs | Added Debug trait to SharedMemorySnapshot struct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff!
Changes LGTM. I left some clarifying comments, but overall good to go.
61713f3 to
74a9260
Compare
bca27e6 to
50f0c0a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM, a few nits but happy to see what other say
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me!
Thanks @ludfjig !
23e1055 to
e45c501
Compare
Not exactly sure. Maybe some usecase for completely state-less guests? Not sure tbh. |
No idea why this doesn't show up as a review comment, anyway my instinct is not to add this now and then if someone wants it add it later, seems like its safer that way |
617adae to
7cb8002
Compare
Signed-off-by: Ludvig Liljenberg <[email protected]>
Signed-off-by: Ludvig Liljenberg <[email protected]>
This PR adds a poison state to sandbox in order to prevent further operations when the sandbox is left in an inconsistent state that could compromise memory safety, data integrity, or security. The sandbox becomes poisoned when guest functions abort/panic or when host-initiated execution cancellation occurs, leaving behind leaked heap allocations, corrupted data structures, or unreleased resources. For example, interrupting execution while guest is allocating can leave the global allocation lock in an inconsistent state, making future allocations impossible in subsequent runs due to infinite locking/spinning.
Poisoned sandboxes will reject all further operations (guest calls, snapshots, memory mapping) until the inconsistent state is resolved through either restoring to a snapshot or manually (unsafely) clearing the poison state.
Closes #848
Round 2:
I've changed the docs and implementation slightly.
is_poison_errorhas been made private. Removed unsafe way of clearing poision. Users of hyperlight are expected on-error to check if the sandbox is poisoned, and deal with it accordingly, for example.